package com.scuvc.service.impl;

import com.scuvc.entity.UserInfo;
import com.scuvc.service.UserInfoService;
import com.scuvc.utils.StaticUtils;

import java.util.List;

public class UserInfoServiceImpl implements UserInfoService {
    @Override
    public boolean login(String account, String password) {
        List<UserInfo> list = StaticUtils.userInfoDao.getUserByAccount(account);
        if(list!=null && list.size()>0){
            if(list.get(0).getPassword().equals(password)){
                return true;
            }
        }
        return false;
    }
    @Override
    public UserInfo getUserInfo(String account) {
        return StaticUtils.userInfoDao.getUserByAccount(account).get(0);
    }

    @Override
    public int register(UserInfo userInfo) {
        return StaticUtils.userInfoDao.insert(userInfo);
    }

    @Override
    public boolean getUser(String account) {
        List<UserInfo> list = StaticUtils.userInfoDao.getUserByAccount(account);
        if(list==null && list.size()==0){
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        boolean flag = StaticUtils.userInfoService.getUser("张三");
        System.out.println(flag);
    }
}
